#--
# Copyright (c) 2007 Maximilian Ott
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#++
#
# Simple controller to display a welcome page and a jump off board
# to the rest of the application.
#
require 'user'

class WelcomeController < ApplicationController
  def index
    # Just show welcome page
  end
  
  # Attempt HTTP authentication, and fall back on a login form.
  # If this method is called login_admin (it's an alias), keep trying
  # until an administrator logs in or the user pushes the "back" button.
  def login
    if flash[:login_succeeded]
      redirect_back_or_default :action => :success
      return
    end

    #@user = User.new
    
    flash[:login_succeeded] = false
  #  http_authorize
  end
  
  # Log out the current user, attempt HTTP authentication to log in a new
  # user. The session information skip_user_setup=true tells the server to
  # generate a new HTTP authentication request and ignore the current HTTP
  # authentication data.
  # We have to request new HTTP authentication here to make the browser
  # forget the old authentication data. Otherwise, the browser keeps sending
  # it!
  #
  def logout
    User.sign_off
    reset_session
    flash[:skip_user_setup] = true
    redirect_to :action => 'index'
  end
  
end
